package AccountWindow.Customer;

import AccountWindow.Customer.PersonalDetailWindow;
import AccountWindow.Customer.RoomDetailWindow.RoomDetailWindow;

import javax.swing.*;
import java.awt.*;

public class CustomerWindow extends JFrame {
    public static String nowAccountID;
    public JPanel customerPanel;
    public CardLayout cardLayout = new CardLayout();
    private JMenuBar menuBar = new JMenuBar();
    private JButton roomDetail = new JButton("客房信息");
    private JButton personalDetail = new JButton("个人信息");

    public RoomDetailWindow roomDetailWindow;
    public PersonalDetailWindow personalDetailWindow;
    private CustomerWindowHandler customerWindowHandler = new CustomerWindowHandler(this);

    public CustomerWindow(String accountID){

        this.nowAccountID = accountID;

        roomDetailWindow = new RoomDetailWindow(nowAccountID);
        personalDetailWindow = new PersonalDetailWindow(nowAccountID);

        customerPanel = new JPanel();
        this.add(customerPanel);
        customerPanel.setLayout(cardLayout);
        placeComponents(customerPanel);

        roomDetail.setActionCommand("roomDetail");
        roomDetail.addActionListener(customerWindowHandler);
        personalDetail.setActionCommand("personalDetail");
        personalDetail.addActionListener(customerWindowHandler);

        this.setBackground(Color.white);
        setTitle("住客界面");
        setBounds(0, 0, 800, 530);
        setLocationRelativeTo(null);//居中显示
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);  //用户单击窗口的关闭按钮时程序执行的操作
        setResizable(false);
        setVisible(true);

    }

    private void placeComponents(JPanel signPanel){
        menuBar.add(roomDetail);
        menuBar.add(personalDetail);

        customerPanel.add(roomDetailWindow,"roomDetailPanel");
        customerPanel.add(personalDetailWindow,"personalDetailPanel");

        this.setJMenuBar(menuBar);

    }

}
